home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d11
/
ev678dev.arc
/
X15BOX.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-07-03
|
8KB
|
281 lines
;------------------------------------------------------------------------
;Example program which sets Everex Extended Mode 15h, 512x480 256 color
;and draws a box around the perimeter of the screen. This code uses
;Everex Extended BIOS function 0004h to get the paging function pointer
;for the particular card installed. This code works on the Everex EVGA
;(Ev673), Everex Viewpoint VGA (Ev678), and the Everex Ultragraphics II
;VGA (Ev236), as well as all future Everex VGA cards, since it uses the
;device independent paging function pointer to perform memory paging.
;------------------------------------------------------------------------
;The paging function is used to change which 64K bank of memory is mapped
;into the CPU address space at segment A000. The banks start at 0 at the
;top of the screen, and increment towards the bottom of the screen. Each
;bank is 64K in size and is read/writeable. This paging function code can
;be applied to high-resolution 16-color modes as well.
;------------------------------------------------------------------------
CR equ 0Dh
LF equ 0Ah
rSequAddr equ 3C4h
rRMiscOutp equ 3CCh
rWMiscOutp equ 3C2h
;------------------------------------------------------------------------
cseg segment word public 'CODE'
assume cs:cseg
assume ds:cseg
assume es:cseg
;------------------------------------------------------------------------
org 0100h
Start:
mov bx,0000h ;Everex Extended BIOS Get Status
mov ax,7000h
int 10h ;Find out if Everex card is present
;and what kind it is.
cmp al,70h ;Abort if not Everex VGA card
je EverexCardDetected
jmp EverexCardNotPresent
EverexCardDetected:
mov ax,0070h
mov bl,15h ;Set Everex Extended 512x480 256-color
int 10h ;mode. Assume that setmode succeeds.
and dx,0FFF0h ;Check card type from Get Status call
cmp dx,6730h ;Is it an EVGA?
je SkipGetPaging
;Note that paging function is called
;AFTER the setmode above.
mov bx,0004h ;Everex Extended Get Paging Function
mov ax,7000h
int 10h
cmp al,70h
je CopyPagingFunction
jmp CantGetPageFunc ;Abort if paging function not supported
CopyPagingFunction:
mov si,es
mov ds,si
mov si,di ;DS:SI -> Paging function in ROM
mov di,cs
mov es,di
mov di,offset ProgPage ;Point to our internal function
mov cx,ds:[si-02h] ;Get size of function in bytes
rep movsb ;Copy function to our memory
mov al,cs:[ExampleRET]
mov es:[di-01h],al ;Patch RETF to RET
SkipGetPaging: ;Re-entry here for EVGA
;We're now in 512x480 256-color mode
;and ProgPage contains a paging function
;for the current Everex VGA card, so
;let's draw the box.
mov di,0A000h
mov es,di ;ES = segment of graphics memory
mov dl,00h ;Note that 512x480 has a neat performance
call SetPage ;advantage in that 512 is a power of 2,
;and thus divides into 65536 (64K) evenly.
;In other words, one 64K bank contains
;exactly 128 scan lines, whereas a 640
;wide mode has a fractional scan line.
mov di,0000h ;Point to first scan line
mov cx,512d/2 ;Fill 512/2 = 256 words
mov ax,0707h ;Fill with white pixels
rep stosw ;Draw top horizontal line
mov ax,479d ;This is an easy example of how to calculate
mov dx,512d ;The page and offset of a scanline or pixel
mul dx ;479 is the scan line we want, and each scan
;line is 512 bytes wide.
add ax,0000h ;Add in the starting X pixel. (This isn't
adc dl,00h ;much here, since X is 0, but it's given as
;and example.)
call SetPage ;Now AX = offset within the bank, and DL
;contains the bank number we need to map
;into our window.
mov di,ax ;Point to last scan line
mov cx,512d/2 ;Fill 512/2 = 256 words
mov ax,0707h ;Fill with white pixels
rep stosw ;Draw bottom horizontal line
mov dl,00h
call SetPage ;Map in top bank
mov di,0000h ;Point to upper left corner of screen
mov bx,512d ;Offset from one pixel to the one below it.
mov cx,480d ;Number of pixels to do vertically
mov al,07h ;Draw white pixels
DrawLeftSideLoop:
mov es:[di],al ;Draw one pixel
add di,bx ;Move down to next
jnc DrawLeftSideCont ;Did we move past the end of a segment
inc dl ;Yes, so move to next page
call SetPage
DrawLeftSideCont:
loop DrawLeftSideLoop ;and loop
mov dl,00h
call SetPage ;Map in top bank
mov di,511d ;Point to upper right corner of screen
mov bx,512d ;Offset from one pixel to the one below it.
mov cx,480d ;Number of pixels to do vertically
mov al,07h ;Draw white pixels
DrawRightSideLoop:
mov es:[di],al ;Draw one pixel
add di,bx ;Move down to next
jnc DrawRightSideCont ;Did we move past the end of a segment
inc dl ;Yes, so move to next page
call SetPage
DrawRightSideCont:
loop DrawRightSideLoop ;and loop
mov dl,00h ;Map bank back to top bank
call SetPage
mov dx,cs
mov ds,dx
mov dx,offset ProgramDoneMesg
mov ah,09h
int 21h
mov ax,4C00h ;Return code OK
int 21h ;Program done
;------------------------------------------------------------------------
EverexCardNotPresent: ;Abort if not Everex VGA card
mov dx,offset NotEverexCardMesg
jmp short OutputErrorMesg
CantGetPageFunc: ;Abort if paging function not supported
mov dx,offset CantGetPageMesg
OutputErrorMesg:
mov ax,cs
mov ds,ax
mov ah,09h
int 21h
mov ax,4C01h ;Exit with error return code
int 21h
;------------------------------------------------------------------------
ActivePage db 00h ;Global variable holding current bank number
ProgramDoneMesg label byte
db 'Program successful.',CR,LF,'$'
NotEverexCardMesg label byte
db 'ERROR: Everex VGA card not detected.',CR,LF,'$'
CantGetPageMesg label byte
db 'ERROR: Can not obtain Everex paging function.',CR,LF,'$'
;------------------------------------------------------------------------
;Memory paging function for Everex EVGA (Ev673) for Everex Extended
;256-color modes. Note that this code only works on the EVGA. For
;other Everex VGA cards, this code will be overwritten with the
;paging function code for the particular Everex VGA card installed.
;------------------------------------------------------------------------
;Entry: DL = page number to select
SetPage proc near
mov cs:[ActivePage],dl ;Keep a copy around for other
;functions to look at, like mouse
;handlers.
ProgPage proc near
push dx
push bx
push ax
mov bl,dl
mov bh,dl
mov dx,rSequAddr ; Set page bit in Sequencer
mov al,8 ; This selects between 0,2 and 1,3
mov ah,al ; Save for later reference
out dx,al
inc dx
jmp short $+2
in al,dx ; Get old value
ror bl,1
and bl,80h
and al,7fh
or al,bl
xchg ah,al ; AL = EvrxCtrl1, AH = new bits
dec dx
out dx,ax
jmp short $+2
and bh,2
shl bh,1
shl bh,1
shl bh,1
shl bh,1
xor bh,20h ; Invert bit
mov dx,rRMiscOutp ; Now read other register
in al,dx
mov dx,rWMiscOutp
and al,0DFh
or al,bh
out dx,al
pop ax
pop bx
pop dx
ret
db (100 - ($ - offset ProgPage)) dup (00h)
;Pad buffer out to 256 bytes
;for copying paging code in here.
ExampleRet label byte ;Used to patch the RETF in the paging
ret ;code to a RET for near calls to
;ProgPage
ProgPage endp
SetPage endp
;------------------------------------------------------------------------
cseg ends
end Start
;------------------------------------------------------------------------